# Contributor: Olliver Schinagl <oliver@schinagl.nl>
# Maintainer: Olliver Schinagl <oliver@schinagl.nl>
pkgname=tpm2-abrmd
pkgver=2.4.0
pkgrel=0
pkgdesc="TPM2 Access Broker & Resource Management Daemon implementing the TCG spec."
url="https://github.com/tpm2-software/tpm2-abrmd"
arch="all"
license="BSD-2-Clause"
depends="dbus libtss2-tcti-armbd"
makedepends="
	autoconf
	autoconf-archive
	automake libtool
	glib-dev
	tpm2-tss-dev
"
install="$pkgname.pre-install"
options="!check"  # Requires IBM TPM simulator
subpackages="
	libtss2-tcti-armbd:libs
	$pkgname-dev
	$pkgname-doc
	$pkgname-openrc
"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/tpm2-software/tpm2-abrmd/archive/$pkgver.tar.gz
	$pkgname.confd
	$pkgname.initd
"

prepare() {
	echo "$pkgver" > "VERSION"
	default_prepare
	autoreconf --install --sym
}

build() {
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix="/usr" \
		--with-dbuspolicydir="/usr/share/dbus-1/system.d" \
		-with-systemdpresetdisable
	make
}

package() {
	make DESTDIR="$pkgdir" install
	rm -f -r "$pkgdir/usr/lib/systemd"

	install -D -m 0755 "$srcdir/$pkgname.initd" \
	        "$pkgdir/etc/init.d/$pkgname"
	install -D -m 0644 "$srcdir/$pkgname.confd" \
	        "$pkgdir/etc/conf.d/$pkgname"
}

sha512sums="
e5459537410f3ec0e6b279e38a555dad8bcea9348b21bb1ebb441ebc0a8df95b969025e6424e24c22cf7cbbae1fdeae9f7da9c569f35fb68b70f74538e72cd8b  tpm2-abrmd-2.4.0.tar.gz
ca7c4782ccc3ee7592bb4b24a6a81c624d22969cf9b9e1c3e22d45e85d3720836b1f22735ccf2ba51258c6eb0b30c4d88d7bed893f58b1aac7423fb7013529f9  tpm2-abrmd.confd
4ccf0a409bc3f92cb9d804a4e380002653e9759e4fa1830e152a8ac46f1039d46229ca80f4fe39ffe4b28a78a36a798a8b081488566a58078af7cbf3a10b14de  tpm2-abrmd.initd
"
